<%@page import="java.util.ArrayList"%>
<%@page import="com.mysql.jdbc.DocsConnectionPropsHelper"%>
<%@page import="java.util.Iterator"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.docman.domainmodel.*;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Arama Sonuç</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
	table.searchInfo th {width:20%; line-height: 2em; background-color: #696265; color: white }
	table.searchInfo td {width:20%}
</style>

<link rel="stylesheet" type="text/css" href="js/jRating/jRating.jquery.css" media="screen" />
<script type="text/javascript" src="js/jRating/jquery.js"></script>
<script type="text/javascript" src="js/jRating/jRating.jquery.js"></script>

<script type="text/javascript">
  $(document).ready(function(){
    $(".rating").jRating({
	  length : 5, // nb of stars
	  decimalLength : 2, // number of decimal in the rate
	  canRateAgain : false,
	  rateMax :5,
	  isDisabled:true,
	  step:false
    });
  });
</script>

</head>
<body>

<div id="main_container">
	<div id="header">
			<div class="logo"><a href="index.jsp"><img src="img/top.png" border="0" alt="" title="" /></a></div>       
	</div>
        <div class="menu">
        	<ul>                                                                         
        		<li><a href="index.jsp">Anasayfa</a></li>
                <li><a href="profileServletpath">Profil</a></li>
                <li><a href="getTagServletpath?sId=0">Dosya Yükleme</a></li>
                <li><a href="getTagServletpath?sId=1">Ayrıntılı arama</a></li>
                <li><a href="contract.jsp">İletişim</a></li>
                <% if(session.getAttribute("currentSessionUser")!= null){ 
                 UserBean user = (UserBean)session.getAttribute("currentSessionUser");%>
                <li><a href="logout.jsp">Çıkış <span style="color: red;">(<span style="font-weight: bold;
                     text-decoration: underline"><%= user.getUserName() %></span>)</span></a></li>
                <% } else { %>
                <li><a href="getUniandDeptServletpath">Kaydol</a></li>
                <% } %>
        	</ul>
        </div>
        
    <div class="center_content">
    	<% if(session.getAttribute("currentSessionUser")!= null){ 
        UserBean user = (UserBean)(session.getAttribute("currentSessionUser"));  
        		ArrayList<DocumentBean> docs = (ArrayList<DocumentBean>)request.getAttribute("docList");
        		Iterator<DocumentBean> iterator = docs.iterator(); %>
        		
        	<fieldset style="margin-left:45em">
			<form action="searchServletpath" method="post">      	
        		<table style="width: 0em">
        			<tr>
        				<td style="font-size:120%; color: #696265; font-weight: 600">Dosya Arama:</td>
        			</tr>
        			<tr>
        				<td><input type="text" name="search" size="20"/></td>
        				<td><input type="submit" class="button" name="submit" value="Ara" style="width: 3.5em"/></td>
        			</tr>
        		</table>        	
        	</form>
        	</fieldset>
        		
        		<br />
        		
        		<table class="searchInfo" border="2" style="width:100%">
        			<tr>
        				<th>Dosya Adı</th>
        				<th>Kategori</th>
        				<th>Dosya Linki</th>
        				<th>Aldığı Oy</th>
        			</tr>
        			<% for(int i=0;i<docs.size();i++){%>
        				<tr>
        		 		<td><%= docs.get(i).getDocName() %></td>
        		 		<td><%= docs.get(i).getTag() %></td>
         				<td><center><a href="documentInfoServletpath?docId=<%= docs.get(i).getDocId() %>"><button class="button">Dosya Sayfası</button></a></center></td>
         				<%double avg =0; 
        		 		if(docs.get(i).getRatingCount()==0){
        		 			avg = 0;
        		 			}
        		 			else
        		 			avg =docs.get(i).getRating()/docs.get(i).getRatingCount();
        		 		 %>
       					<td><div class="rating" data-average="<%=avg%>" data-id="" style="width: 2em; height: 1em; overflow: hidden; z-index: 1; position: relative; cursor: default;"></div></td></td>
       					</tr>
       				<% } %>       			
         		</table>
        <% }else { %>
			<p style="font-size: 1.5em; text-align: center;color:red">Lütfen <a href="index.jsp">Anasayfa</a>'dan giriş yapınız.  </p>	
			<p style="font-size: 1.5em; text-align: center;color:red">Veya menüden Kaydol butonuna tıklayıp sitemize üye olabilirsiniz. </p>
		<% } %>
                   

    </div>
         
</div>

</body>
</html>